package com.pu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.pu.dto.SetmealPageQueryDTO;
import com.pu.entity.Setmeal;
import com.pu.vo.DishItemVO;
import com.pu.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @Author Yusc
 * @Date 2023/10/26 17:09
 * @Version
 * @Description 套餐管理业务层
 **/
@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {
    /**
     * @param setmealPageQueryDTO
     * @auther: Yusc
     * @date 2023/10/28 20:27
     * @Description 分页条件查询
     */
    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    /**
     * @param id 套餐id
     * @auther: Yusc
     * @date 2023/10/31 19:41
     * @Description 根据套餐id查询包含的菜品列表
     */
    @Select("select sd.name, sd.copies, d.image, d.description " +
            "from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
            "where sd.setmeal_id = #{setmealId}")
    List<DishItemVO> getDishItemBySetmealId(Long id);

    /**
    * @auther: Yusc
    * @date 2023/11/8 18:15
    * @Description 查询套餐总览
    */
    Integer countByMap(Map map);
}
